/*
 * This file (RxPoster.java) is protected by the GNU GPL licence (v2). 
 * Please read the license.txt attached for further informations. 
 * 
 */

package alkwarel.filters;

import alkwarel.objects.AkArtspace;
import alkwarel.objects.RxFilter;
import artx.parameters.AxIntParameter;

/**
 * Poster
 * 
 * @author Xavier Gouchet
 * 
 */
public class RxPoster extends RxFilter {

	private int level = 5;

	/**
	 * Standard constructor.
	 */
	public RxPoster() {
		super(4007, "poster", new String[] { "poster level", "int" });
	}

	/**
	 * @see alkwarel.objects.RxFilter#Apply(alkwarel.objects.AkArtspace)
	 */
	public final boolean Apply(AkArtspace a) {
		AxIntParameter param = (AxIntParameter) a.GetParameterManager().GetElement("poster level");
		if (param != null){
			this.level = param.GetValue();
		}
		for (int x = 0; x < a.width; x++) {
			for (int y = 0; y < a.height; y++) {
				this.RGBHSV(a.get(x, y));

				this.S((1000 / this.level) * (ssat / (1000 / this.level))
						+ (1000 / this.level) / 2);
				this.H((360 / this.level) * (hhue / (360 / this.level))
						+ (360 / this.level) / 2);
				this.V((256 / this.level) * (vval / (256 / this.level))
						+ (256 / this.level) / 2);

				this.HSVRGB();
				a.set(x, y, this.coulref);
			}
		}
		return true;
	}
}
